//
//  ChartViewController.m
//  iBook
//
//  Created by wangjing on 14/12/3.
//  Copyright (c) 2014年 wikiflyer. All rights reserved.
//

#import "ChartViewController.h"
#import "ShuJiXiangQing_ViewController.h"

#define MRScreenHeight     CGRectGetHeight([UIScreen mainScreen].applicationFrame)
#define MRScreenWidth      CGRectGetWidth([UIScreen mainScreen].applicationFrame)

@interface ChartViewController ()

@end

@implementation ChartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self initNavigation];
    
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    [_myTableV setTableFooterView:view];
    [_myTableV setBackgroundColor:[UIColor whiteColor]];
    [self.view addSubview:_myTableV];
    
    
}
/**
 *  初始化导航栏
 */
-(void)initNavigation{
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"类别" style:UIBarButtonItemStyleDone target:self action:@selector(clickCateBtn)];
    self.navigationItem.title = @"热门作者";
}
/**
 *  点击类别按钮
 */
-(void)clickCateBtn{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString * str1=@"123";
    UITableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:str1];
    if (!cell) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str1];
    }
    UILabel * lable1=[[UILabel alloc] initWithFrame:CGRectMake(20, 10, 80, 30)];
    lable1.text=@"免费";
    [cell addSubview:lable1];
    
    UIButton * btn1=[UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame=CGRectMake(MRScreenWidth-100, 15, 80, 25);
    btn1.titleLabel.font=[UIFont systemFontOfSize:14];
    [btn1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [btn1 setTitle:@"显示全部" forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(goBtn1) forControlEvents:UIControlEventTouchUpInside];
    [cell addSubview:btn1];
    
    [self initWithScrollView:nil];
    [cell addSubview:_myScrollV];
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 260;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - myScrollView
-(void)initWithScrollView:(NSMutableArray *)theArray{
    
    _arrayDatas=[[NSMutableArray alloc] init];
    for (int a=0; a<9; a++) {
        [_arrayDatas addObject:@"1"];
    }
    theArray=_arrayDatas;
    
    _myScrollV=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 40, MRScreenWidth, 220)];
    _myScrollV.showsVerticalScrollIndicator = FALSE;
    _myScrollV.showsHorizontalScrollIndicator = FALSE;
    _myScrollV.contentSize=CGSizeMake(15+(theArray.count-1)*95+80+15, 220);
    for (int a=0; a<theArray.count; a++) {
        UIButton * myBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        myBtn.frame=CGRectMake(15+a*95, 20, 80, 180);
        myBtn.titleLabel.font=[UIFont systemFontOfSize:14];
        [myBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [myBtn setTitle:@"显示全部" forState:UIControlStateNormal];
        [myBtn addTarget:self action:@selector(goBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_myScrollV addSubview:myBtn];
        
        UIImageView * imageV=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 120)];
        imageV.image=[UIImage imageNamed:@"1.jpg"];
        [myBtn addSubview:imageV];
        
        UILabel * labelx1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120+15, 80, 15)];
        labelx1.text=@"足球宝贝";
        labelx1.font=[UIFont systemFontOfSize:12];
        [myBtn addSubview:labelx1];
        
        UILabel * lablex2=[[UILabel alloc] initWithFrame:CGRectMake(0, 120+30, 80, 30)];
        lablex2.font=[UIFont systemFontOfSize:12];
        lablex2.numberOfLines=0;
        lablex2.text=@"适用于ios8及以下版本";
        [myBtn addSubview:lablex2];
    }
    
    
}


#pragma mark - btn
-(void)goBtn1{
    NSLog(@"显示全部");
}
-(void)goBtn:(UIButton *)btn{
    ShuJiXiangQing_ViewController * shujiV=[[ShuJiXiangQing_ViewController alloc] init];
    [self.navigationController pushViewController:shujiV animated:YES];
}


@end
